<?xml version="1.0" encoding="utf-8" ?>
<Feature id="MediaStore" name="Media Storage and Management feature">
	<Dependencies>
		<Dependency type="feature">FileSystemFeature.xml</Dependency>
	</Dependencies>

	<Macro name="MaxImageCacheCatFile">10</Macro>

	<BusinessObjects>
		<BusinessObject type="MediaCacheAppFunction" extends="DynamicAppFunction" key="id">
			<Field name="isMediaCache" type="Boolean">True</Field>
		</BusinessObject>

		<BusinessObject type="MediaItem" key="id">
			<Method name="id" language="jscript.NET">
				<![CDATA[
		return self.getItem("name").Replace('/','_').Replace(' ','').Replace('.','');
		]]>
			</Method>
			<Field name="name" type="String" />
			<Field name="location" type="String" />
			<Field name="type" type="String" />
			<Field name="cacheName" type="String" />
			<Field name="selected" type="Boolean" />
			<Field name="file" type="FileSysFile" />
			<Field name="previewUrl" type="String" />
		</BusinessObject>

		<BusinessObject type="MediaItemDirectory" key="keyName" >
			<Field name="keyName" type="String" />
			<Field name="name" type="String" />
			<Field name="parentName" type="String" />
			<Field name="depth" type="Integer" />
			<Method name="shortDepthName" language="jscript.NET">
				<![CDATA[
			var depth : Int32 = self.getItem("depth");
			var str = "";
			for(var p = 0; p < depth; p++)
				  str+="&nbsp;&nbsp;";
			return (str.replace(/\&/g,"#&#") + self.getItem("name")).ToString();
		]]>
			</Method>
			<Method name="depthName" language="jscript.NET">
				<![CDATA[
			var depth : Int32 = self.getItem("depth");
			var str = "";
			for(var p = 0; p < depth; p++)
				  str+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			return (str.replace(/\&/g,"#&#") + self.getItem("name")).ToString();
		]]>
			</Method>
			<Method name="spacedDepthName" language="jscript.NET">
				<![CDATA[				
				var depth : Int32 = self.getItem("depth");
				var str = self.getItem("name");
				if(depth != 0) {
					var buff = new StringBuilder(100);
					for(var c = 0; c < depth; c++)
						buff.Append("     ");
					buff.Append(str);
					str = buff;
				}
				return str;
			]]>
			</Method>

			<Field name="cacheName" type="String" />
			<Field name="fileCount" type="Integer" />
		</BusinessObject>

		<BusinessObject type="Image" extends="MediaItem" key="id">
			<Field name="width" type="Integer" />
			<Field name="height" type="Integer" />
			<Field name="imageProperties" type="ImageProperties" />
			<Method name="takenDate" language="jscript.NET">
				<![CDATA[
				var dc = self.getItem("imageProperties.DateTimeOriginal");
				if(Cmn.IsEmpty(dc))
					return self.getItem("file.dateCreated");
				return dc;
			]]>
			</Method>
		</BusinessObject>

		<BusinessObject type="VideoMedia" extends="MediaItem" key="id">
			<Field name="width" type="Integer" />
			<Field name="height" type="Integer" />
			<Field name="snapshotPos" type="Double" />
			<Field name="previewPos" type="Double" />
			<Field name="previewDuration" type="Double" />
		</BusinessObject>

		<BusinessObject type="ImageProperties" key="id">
			<Field name="id" type="Guid" />
			<Field name="DateTime" type="String" />
			<Field name="ImageWidth" type="String"  />
			<Field name="ImageLength" type="String"  />
			<Field name="BitsPerSample" type="String" />
			<Field name="Compression" type="String" />
			<Field name="XResolution" type="String" />
			<Field name="YResolution" type="String" />
			<Field name="ResolutionUnit" type="String" />
			<Field name="ImageDescription" type="String" />
			<Field name="Make" type="String" />
			<Field name="Model" type="String" />
			<Field name="Software" type="String" />
			<Field name="Artist" type="String" />
			<Field name="Copyright" type="String" />
			<Field name="ColorSpace" type="String" />
			<Field name="PixelXDimension" type="String" />
			<Field name="PixelYDimension" type="String" />
			<Field name="ComponentsConfiguration" type="String" />
			<Field name="CompressedBitsPerPixel" type="String" />
			<Field name="RelatedSoundFile" type="String" />
			<Field name="DateTimeOriginal" type="String" />
			<Field name="DateTimeDigitized" type="String" />
			<Field name="DigitalZoomRatio" type="String" />
			<Field name="Contrast" type="String" />
			<Field name="Saturation" type="String" />
			<Field name="Sharpness" type="String" />
			<Field name="Flash" type="String" />
			<Field name="MakerNote" type="String" />
			<Field name="Orientation" type="String" />
			<Field name="SamplesPerPixel" type="String" />
			<Field name="SubjectLocation" type="String" />
			<Field name="UserComment" type="String" />
		</BusinessObject>

		<BusinessObject type="ImageAdjustment" key="name">
			<Field name="name" type="String" />
			<Field name="imageType" type="String">*</Field>
			<Field name="width" type="Integer" />
			<Field name="height" type="Integer" />
			<Field name="maintainAspectRatio" type="Boolean">true</Field>
			<Field name="quality" type="Integer">75</Field>
			<Field name="watermarkImage" type="String" />
			<Field name="watermarkText" type="String" />
			<Field name="watermarkPos" type="String">topLeft</Field>
			<Field name="mediaType" type="String">Image</Field>
			<Field name="goodForGeneralPreview" type="Boolean">True</Field>
		</BusinessObject>

		<BusinessObject type="Scaling" key="name">
			<Field name="name" type="String" />
			<Field name="adjustments" type="List(ImageAdjustment)" />
		</BusinessObject>

		<BusinessObject type="ImageCache" key="id">
			<Field name="id" type="String" xmlOut="none" />
			<Field name="name" type="String" />
			<Field name="cryptoName" type="String">
				<NULL/>
			</Field>
			<Field name="isDefault" type="Boolean" xmlOut="none">False</Field>
			<Field name="extensionName" type="String" />
			<Field name="fileFilter" type="String">
				*.jpg;*.jpeg;*.tif;*.tiff;*.gif;*.bmp;*.png
			</Field>
			<Field name="scalings" type="List(Scaling)" />
			<Field name="previewBaseUrl" type="String" />
		</BusinessObject>
		<BusinessObject type="FileSysImageCache" extends="ImageCache" key="id">
			<Field name="origionalImagesLocation" type="String" />
			<Field name="baseCacheLocation" type="String" />
		</BusinessObject>

		<BusinessObject type="VideoImageCache" extends="FileSysImageCache" key="id">
		</BusinessObject>

		<BusinessObject type="ImageCacheDisplayOptions" key="id">
			<Field name="id" type="Guid" />
			<Field name="drillDown" type="Boolean" />
		</BusinessObject>

		<BusinessObject type="DataAccessImageCache" extends="ImageCache" key="id">
			<Field name="getList" type="String" />
			<Field name="getImage" type="String" />
			<Field name="addImage" type="String" />
			<Field name="deleteImage" type="String" />
			<Field name="updateImage" type="String" />
			<Field name="getImagesMatch" type="String" />
			<Field name="getImageId" type="String" />
		</BusinessObject>
		<BusinessObject type="MediaLocation" key="name">
			<Field name="name" type="String" />
			<Field name="fullName" type="String" />
			<Field name="childDirs" type="List(MediaLocation)" />
		</BusinessObject>

		<BusinessObject type="ImageCacheImage" extends="Image" key="id">
			<Field name="adjustName" type="String">
				<NULL/>
			</Field>
		</BusinessObject>

		<BusinessObject injects="UserSettings">
			<Field name="imageScalingName" type="String" />
			<Field name="imageCacheUsage" type="Integer" />
		</BusinessObject>

		<BusinessObject injects="CompanySettings">
			<Field name="defaultMediaCache" type="String" >img/syrinxdevcomimages</Field>
			<Field name="defaultMediaCatalogName" type="String">syrinxdevcomimages</Field>
			<Field name="defaultMediaName" type="String">blank.gif</Field>
		</BusinessObject>
		<BusinessObject injects="UserLimits">
			<Field name="maxGalleries" type="Integer" />
			<Field name="maxTotalAlbums" type="Integer" />
			<Field name="maxImages" type="Integer" />
			<Field name="maxImageSize" type="Integer" />
			<Field name="maxImageCacheSize" type="Integer" />
		</BusinessObject>
		<BusinessObject injects="CompanyLimits">
			<Field name="maxGalleries" type="Integer" />
			<Field name="maxTotalAlbums" type="Integer" />
			<Field name="maxImages" type="Integer" />
			<Field name="maxImageSize" type="Integer" />
			<Field name="maxImageCacheSize" type="Integer" />
		</BusinessObject>
	</BusinessObjects>

	<BusinessRules>
		<BusinessRule name="getMediaItemDirectories" security="disabled">
			<LocalClass name="MediaCache.BusinessRules,ScsCore" />
		</BusinessRule>

		<BusinessRule name="getImageList" security="disabled">
			<LocalClass name="MediaCache.BusinessRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getImage" security="disabled">
			<LocalClass name="MediaCache.BusinessRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getMediaLocationDirectories" security="disabled">
			<LocalClass name="MediaCache.BusinessRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getMediaItemsFromDirectory" security="disabled">
			<LocalClass name="MediaCache.BusinessRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getImageFileInfo" security="disabled">
			<LocalClass name="MediaCache.BusinessRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getImageCacheDetails" security="disabled">
			<LocalClass name="MediaCache.BusinessRules,ScsCore" />
		</BusinessRule>
    <BusinessRule name="isImageInMediaCache" security="disabled">
      <LocalClass name="MediaCache.BusinessRules,ScsCore" />
    </BusinessRule>
    

    <BusinessRule name="getCompanyMediaCacheLibraries" security="disabled">
			<LocalClass name="MediaCache.CompanyMediaCacheBizRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getCompanyScalings" security="disabled">
			<LocalClass name="MediaCache.CompanyMediaCacheBizRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getCompanyMediaCacheAppFunctions" security="disabled">
			<LocalClass name="MediaCache.CompanyMediaCacheBizRules,ScsCore" />
		</BusinessRule>
		<BusinessRule name="getMediaCacheCompanySettings" postExtends="getCompany" security="disabled" >
			<LocalClass name="MediaCache.CompanyMediaCacheBizRules,ScsCore" />
		</BusinessRule>
	</BusinessRules>

	<BusinessRules>
		<BusinessRule name="addImage" disabled="true" security="disabled" />
		<BusinessRule name="removeImage" disabled="true" security="disabled" />
		<BusinessRule name="updateCompanyImageCacheLibrary" disabled="true" security="disabled" />
	</BusinessRules>

	<DarExtensions from="MediaCache" for="UserLogin" />


	<ApplicationData>
		<Entry name="images" nodeType="catalog from $CatalogHome$/ImageCache">use ImageCacheTypes factory</Entry>
		<Entry name="defaultImageCacheSetting" type="IBizObj.FileSysImageCache">
			<FileSysImageCache name="images" extensionName="image" isDefault="True" >
				<origionalImagesLocation>$BaseCacheStore$</origionalImagesLocation>
				<baseCacheLocation>$BaseCacheStore$</baseCacheLocation>
				<scalings>
					<Scaling name="">
						<ImageAdjustment name="Thumbnail" width="120" height="0" maintainAspectRatio="True" quality="75" />
						<ImageAdjustment name="WideThumbnail" width="111" height="40" maintainAspectRatio="False" quality="75" />
						<ImageAdjustment name="SmallThumbnail" width="70" height="0" maintainAspectRatio="True" quality="65" />
						<ImageAdjustment name="Medium" width="450" height="0" maintainAspectRatio="True" quality="65" />
						<ImageAdjustment name="SmallMedium" width="225" height="0" maintainAspectRatio="True" quality="65" />
						<ImageAdjustment name="Large" width="1150" height="0" maintainAspectRatio="True" quality="85" />
						<ImageAdjustment name="MainLogon1" width="210" height="70" maintainAspectRatio="True" quality="85"/>
						<ImageAdjustment name="HomeSplash" width="650" height="235" maintainAspectRatio="True" quality="85"/>
					</Scaling>
				</scalings>
			</FileSysImageCache>
		</Entry>
		<Entry name="MediaCacheNamePrefix" type="String">img/</Entry>
	</ApplicationData>

  <ApplicationFunctions id="MediaCache" description="Media Libraries">
    <DynamicAppFunction id="MediaCacheAppFunctions" bizrule="getCompanyMediaCacheAppFunctions" 
                        bizobjType="MediaCacheAppFunction" scope="companyId"/>
  </ApplicationFunctions>

	<ClassFactory id="ImageCacheTypes">
		<Class type="MediaCache.FileSysImageCache,ScsCore" />
		<Class type="MediaCache.VideoImageCache,ScsCore" />
		<Class type="MediaCache.DataAccessImageCache,ScsCore" />
	</ClassFactory>

	<ClassFactory id="BizProcs">
		<Class type="MediaCache.Gui.MediaDirectoryBizProc,ScsCore" name="mediaDirectoryLibrary"/>
		<Class type="MediaCache.Gui.MediaDirectoryItemsBizProc,ScsCore" name="mediaImagesLibrary"/>
		<Class type="MediaCache.Gui.MediaCacheUploadBizProc,ScsCore" name="mediaUpload"/>
		<Class type="MediaCache.Gui.MediaCacheManagementBizProc,ScsCore" name="mediaCache"/>
		<Class type="MediaCache.Gui.MediaCacheScalingsBizProc,ScsCore" name="cacheScalings"/>
		<Class type="MediaCache.Gui.MediaCacheScalingSettingsBizProc,ScsCore" name="scalingSettings"/>
	</ClassFactory>
</Feature>
